#ifndef __M26_API_H__
#define __M26_API_H__	 

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>

#include "nstar_m26_dev.h"

//需要外部实现: 
#include "share.h"
#define m26_dbg(fmt, args...)\
do {\
    ebmdbg_4g("4g net: "fmt, ##args);\
}while(0)


//#define LINE_BUSY_CHECK() at_ch_check()
#define LINE_BUSY_CHECK()	0
#define LINE_BUSY_GET() 	1
#define AT_4051_SET()		at_ch_set()
#define AT_4051_CLEAR()		at_ch_clear()

//........................

#define M26Timer_Expired(ptimer, n_sec)	app_capture_interval(ptimer, 1000*n_sec)
#define	M26Timer_Update(ptimer)			app_update_interval(ptimer)	


#define CPS_MAX  50			//白名单数

#define delay_ms(n)	usleep(n*1000)
#define delay_s(n)	delay_ms(n*1000)


extern void at_ch_set(void);
extern void at_ch_clear(void);

struct m26_para{
	long TIMER_Errcnt;		//初始化步骤时报错时间，默认60
	long TIMER_Check_Sq;	//检查信号间隔，默认20
	long ATA_RingCnt;		//接电话振铃数，默认3
	//unsigned char ntpip[57];		//sim808用，默认ntp1.aliyun.com
	unsigned char remote_ip[4];
	unsigned short remote_port;
};

//运行状态
enum 
{
	M26_PWR_OFF=0,
	M26_PWR_ON, 			
	M26_CFG_TOP,			
	M26_CHECK_SIGNAL,	
	M26_CHECK_CPIN,		
	M26_CHECK_QNS,
	M26_CFG_BOTTOM,
	M26_INIT_OK,		
	M26_GRMS_GETTIME,	
  	M26_GRMS_CONNECT,	
  	M26_GRMS_ESTABLISHED,	
  	M26_STPE_MAX
};

//异常信息	
enum 
{
	M26_HARDWARE_INITING=0,
	M26_HARDWARE_OK,
	M26_HARDWARE_ERR,
};


//私有计时器
enum{
	PriTimer_State_Machine,
	TIMER_Errcnt,
	TIMER_Sms_loop,
	TIMER_Sms_Errcnt,
	TIMER_Ata_loop,
	TIMER_NET_loop,
	TIMER_Check_Sq=0x7,
	TIMER_ARRAY_SIZE=0x8,
};



void M26_servo(void *para, int gaps);
void M26_do_reboot_module(void);
unsigned char M26_scale_sq(void);

unsigned char cmd_play_tts(unsigned char mode, const unsigned char *buf, unsigned short len);

unsigned char lan_err_check(void);



#endif


